Skip to content

👌 IMPROVE: MathJax 4 compatibility (Sphinx 9)#1110

Merged
chrisjsewell merged 5 commits intoexecutablebooks:masterfrom
ilia-kats:mathjax4
May 8, 2026
Merged

👌 IMPROVE: MathJax 4 compatibility (Sphinx 9)#1110
chrisjsewell merged 5 commits intoexecutablebooks:masterfrom
ilia-kats:mathjax4

Conversation

@ilia-kats
Copy link
Copy Markdown
Contributor

@ilia-kats ilia-kats commented Mar 4, 2026

Sphinx 9 introduced mathjax4_config alongside the existing mathjax3_config. This PR updates MyST-Parser's mathjax override logic to handle both.

Changes

  • Remove dead Sphinx 3 / MathJax 2 code path (mathjax_config['tex2jax']) — MyST-Parser requires Sphinx ≥ 8
  • Add mathjax4_config support: prefer whichever config the user has explicitly set, falling back to the Sphinx version's default (mathjax4_config for Sphinx 9+, mathjax3_config for 8)
  • Ensure processHtmlClass is always applied even when no user mathjax config is pre-set
  • Simplify log_override_warning to use the actual config attribute name
  • Fix typo in module docstring ("mrakdown-it-py" → "markdown-it-py")

Tests added

  • test_mathjax_default — verifies processHtmlClass is set with no user config
  • test_mathjax_no_override — verifies myst_update_mathjax=False skips override
  • test_mathjax4_warning — verifies warning when overriding mathjax4_config (Sphinx 9+)
  • test_mathjax3_config_on_sphinx9 — verifies explicit mathjax3_config is still respected on Sphinx 9

pre-commit-ci Bot and others added 4 commits March 4, 2026 14:30
- Remove dead Sphinx 3 / MathJax 2 code path (`mathjax_config['tex2jax']`)
  since only Sphinx >=8 is supported.
- Add mathjax4_config support for Sphinx 9, preferring whichever config
  the user has explicitly set.
- Fix default case: processHtmlClass is now always applied even when no
  user mathjax config is set.
- Simplify log_override_warning to use the actual config attribute name
  instead of a version number.
- Add tests for default config, myst_update_mathjax=False, and
  mathjax4_config override warning (Sphinx 9 only).
@chrisjsewell chrisjsewell changed the title mathjax4 compatibility 👌 IMPROVE: MathJax 4 compatibility (Sphinx 9) May 8, 2026
@chrisjsewell
Copy link
Copy Markdown
Member

Thanks @ilia-kats , I took the chance to do a bit more cleaning up of the code, and updated the pr description

@chrisjsewell chrisjsewell merged commit 0fb1ae9 into executablebooks:master May 8, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants